-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrations(shared-views): Create groupsearchviewlastvisited
table
#86241
base: master
Are you sure you want to change the base?
Conversation
This PR has a migration; here is the generated SQL for --
-- Create model GroupSearchViewLastVisited
--
CREATE TABLE "sentry_groupsearchviewlastvisited" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "user_id" bigint NOT NULL, "last_visited" timestamp with time zone NOT NULL, "group_search_view_id" bigint NOT NULL, "organization_id" bigint NOT NULL, CONSTRAINT "sentry_groupsearchviewlastvisited_unique_last_visited_per_org_user_view" UNIQUE ("user_id", "organization_id", "group_search_view_id"));
ALTER TABLE "sentry_groupsearchviewlastvisited" ADD CONSTRAINT "sentry_groupsearchvi_group_search_view_id_ba7312f8_fk_sentry_gr" FOREIGN KEY ("group_search_view_id") REFERENCES "sentry_groupsearchview" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_groupsearchviewlastvisited" VALIDATE CONSTRAINT "sentry_groupsearchvi_group_search_view_id_ba7312f8_fk_sentry_gr";
ALTER TABLE "sentry_groupsearchviewlastvisited" ADD CONSTRAINT "sentry_groupsearchvi_organization_id_0c751d81_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_groupsearchviewlastvisited" VALIDATE CONSTRAINT "sentry_groupsearchvi_organization_id_0c751d81_fk_sentry_or";
CREATE INDEX CONCURRENTLY "sentry_groupsearchviewlastvisited_user_id_b4c3778c" ON "sentry_groupsearchviewlastvisited" ("user_id");
CREATE INDEX CONCURRENTLY "sentry_groupsearchviewlastvisited_group_search_view_id_ba7312f8" ON "sentry_groupsearchviewlastvisited" ("group_search_view_id");
CREATE INDEX CONCURRENTLY "sentry_groupsearchviewlastvisited_organization_id_0c751d81" ON "sentry_groupsearchviewlastvisited" ("organization_id"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration lgtm
groupsearchviewlastseen
table groupsearchviewlastvisited
table
renamed everything to last_visited (instead of last_seen) since this aligns with prior art (saved explore and discover queries) |
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #86241 +/- ##
===========================================
+ Coverage 56.38% 87.88% +31.50%
===========================================
Files 9714 9722 +8
Lines 550669 551067 +398
Branches 21478 21478
===========================================
+ Hits 310510 484322 +173812
+ Misses 239806 66392 -173414
Partials 353 353 |
db_table = "sentry_groupsearchviewlastvisited" | ||
constraints = [ | ||
UniqueConstraint( | ||
fields=["user_id", "organization_id", "group_search_view_id"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jfyi: Since these are fks, you can refer to the column name vs the id, so organization
instead of organization_id
.
You don't need to change it, both are fine.
This PR creates a new table,
groupsearchviewlastvisited
. More details on why we are doing this can be found in this tech spec (internal only).TL;DR — We need a table to keep track of when the last time a user looks at view.